package utils

import (
	"math"
	"strconv"
)

func ReadableFileSize(size int64) string {

	if size <= 0 {
		return "0"
	} else {
		units := [...]string{"B", "kB", "MB", "GB", "TB", "EB"}
		digitGroups := int(math.Log10(float64(size)) / math.Log10(1024.0))
		return strconv.Itoa(int(float64(size)/math.Pow(1024.0, float64(digitGroups)))) + "" + units[digitGroups]
	}

}
